#--
# Copyright (c) 2007 Mathew Abonyi
# Please read LICENSE document for more information.
#++

require 'ostruct'

module Retrospectiva
  module Extension
    module SCMTicketUpdate

      # TicketReference is just an OpenStruct with additional hash access.
      #
      # Since all a ticket reference does is carry data from a parsed log
      # message to Retrospectiva for translation into real updates, it does
      # not need to do anything, really. It's just a convenient container.
      #
      # TicketReference objects are created by Update with data from Parser.
      #
      class TicketReference < OpenStruct

        def each
          @table.each { |k,v| yield k, v }
        end

        # Hack for Ruby to prevent deprecation warnings
        def id
          @table[:id]
        end

        # Hash reading
        def [](key)
          @table[key]
        end

        # Hash writing
        def []=(key, val)
          @table[key] = val
        end

      end

    end # SCMTicketUpdate
  end
end